//
//  NoDataCustomView.swift
//  DKE-Album
//
//  Created by 杨东宝 on 2020/6/21.
//  Copyright © 2020 杨东宝. All rights reserved.
//

import UIKit
// 数据传输协议
protocol NoDataCustomViewDelegate: AnyObject {
    func didClick()
}
class NoDataCustomView: UIView, UIGestureRecognizerDelegate {
    weak var delegate: NoDataCustomViewDelegate?
    //MARK:-图片
    lazy var noDataImage: UIImageView = {
        let noDataImage = UIImageView()
        addSubview(noDataImage)
        noDataImage.isUserInteractionEnabled = true
        let tapGesture = UITapGestureRecognizer(target: self, action: #selector(backgroundTapped))
        tapGesture.delegate = self
        noDataImage.addGestureRecognizer(tapGesture)
        return noDataImage
    }()
    
    //MARK:-提示语
     lazy  var nodataLabel: UILabel = {
         let label = UILabel()
         label.font = DIMENSION_FONT_OF_SIZE(14)
         label.textColor = hexColor(0x666666,0xBBBBBB)
         addSubview(label)
         label.isUserInteractionEnabled = true
         return label
     }()
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.isUserInteractionEnabled = true
        self.backgroundColor = HexRGB(0x666666)
        addSubViews()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    @objc private func backgroundTapped(_ gesture: UITapGestureRecognizer) {
        self.delegate?.didClick()
    }
    func addSubViews() {
        
        noDataImage.snp.makeConstraints { (make) in
            make.width.height.equalTo(DIMENSION_VALUE(100))
            make.centerX.equalToSuperview()
            make.top.equalToSuperview()
        }
        nodataLabel.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(noDataImage.snp_bottom).offset(DIMENSION_VALUE(15))
            make.height.equalTo(DIMENSION_VALUE(25))
        }
        
    }

}
